home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / rand.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  340 b   |  24 lines

  1. #include "lib.h"
  2.  
  3. static long __seed = 1L;
  4.  
  5. int rand()
  6. {
  7.   __seed = (1103515245L * __seed + 12345) & 0x7FFFFFFF;
  8. #ifdef __GNUC__
  9. #ifdef __MSHORT__
  10.   return((int) ((__seed >> 16) & 077777));
  11. #else
  12.   return((int) __seed);
  13. #endif
  14. #else
  15.   return((int) ((__seed >> 16) & 077777));
  16. #endif
  17. }
  18.  
  19. void srand(val)
  20. unsigned int val;    
  21. {
  22.     __seed = val;
  23. }
  24.